//
//  YZMAnnouncementDetailCell.m
//  YZMicroStock
//
//  Created by Lv.Dongdong on 2017/3/9.
//  Copyright © 2017年 cqjr. All rights reserved.
//

#import "YZMAnnouncementDetailCell.h"

@interface YZMAnnouncementDetailCell ()

@property (nonatomic, strong) UILabel *contentLB;
@property (nonatomic, strong) UILabel *showLB;

@end

@implementation YZMAnnouncementDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        [self createObjects];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}

- (void)createObjects {
    
    WS(ws);
    
    self.contentLB = [YZMAppStyle labelWithMediumWhite];
    self.contentLB.numberOfLines = 0;
    [self.contentView addSubview:self.contentLB];
    [self.contentLB mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(ws.contentView).offset(10);
        make.left.equalTo(ws.contentView).offset(20);
        make.right.equalTo(ws.contentView).offset(-20);
    }];
    
    self.showLB = [YZMAppStyle labelWithSmallLightGray];
    self.showLB.textColor = [YZMAppStyle colorForBlueText];
    self.showLB.text = @"收起";
    [self.contentView addSubview:self.showLB];
    [self.showLB mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(ws.contentLB.mas_bottom).offset(15);
        make.bottom.equalTo(ws.contentView).offset(-11);
        make.right.equalTo(ws.contentView).offset(-20);
    }];
    
    self.bottomLine = [YZMAppStyle splitLine];
    [self.contentView addSubview:self.bottomLine];
    [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.left.right.equalTo(ws.contentView);
    }];
}

- (void)setModel:(YZMAnnouncementListModel *)model {
    
    if ([model.noticeContent rangeOfString:@"</"].location != NSNotFound) {
        
        self.contentLB.attributedText = [model attributeWithHTML];
    } else {
        
        self.contentLB.text = model.noticeContent;
    }
}

@end
